<?php
header ( "Content-type: text/html; charset=utf-8" ); 
	session_start();
	include "../conn/conn.php";
	$head_path = "upfiles\\head";
	$picture_path="";
	if ((($_FILES["picture"]["type"] == "image/gif")|| ($_FILES["picture"]["type"] == "image/jpeg")|| ($_FILES["picture"]["type"] == "image/pjpeg"))	&& ($_FILES["picture"]["size"] < 20000))
	  	{
			 $picture_path=date('YmdGis').rand(1000,999).$_FILES["picture"]["name"];
			move_uploaded_file($_FILES['picture']['tmp_name'],$head_path."\\".$picture_path);
		 
		  }
	else
	  {
	 echo "<script>alert('上传图片失败！');history.go(-1);</script>";
	 exit();
	  }
	$sql = "select * from tb_video where name = '".$_POST['name']."'";
	$result=mysqli_query($link,$sql);
	if(mysqli_num_rows($result)>0){
	  echo "<script>alert('商品名重复，请重新输入');history.go(-1);</script>";
		}
     else{
		 
		 $sql_in= "insert into tb_video(name,style,remark,intro,picture) values ('".$_POST['name']."','".$_POST['style']."','".$_POST['remark']."','".$_POST['intro']."','".$picture_path."')";
		 mysqli_query($link,$sql_in);
		 echo"<script>alert('添加成功');window.location.href='food_gl.php';</script>";
		 
		 }

?>